<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录 - 七码题库系统</title>
    <link rel="stylesheet" href="/static/assets/libs/layui/css/layui.css" />
    <link rel="stylesheet" href="/static/assets/css/login.css?v=312">
    <script>
        if (window != top) {
            top.location.replace(location.href);
        }
    </script>
</head>

<body>
    <div class="login-wrapper">
        <div class="login-header">
            <img src="/static/img/logo.png">
        </div>
        <div class="login-body">
            <div class="layui-card">
                <div class="layui-card-header">
                    <i class="layui-icon layui-icon-engine"></i>&nbsp;&nbsp;用户登录
                </div>
                <form class="layui-card-body layui-form layui-form-pane">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                        <div class="layui-input-block">
                            <input name="username" type="text" placeholder="账号" class="layui-input" lay-verType="tips"
                                lay-verify="required" required />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                        <div class="layui-input-block">
                            <input name="password" type="password" placeholder="密码" class="layui-input"
                                lay-verType="tips" lay-verify="required" required />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><i class="layui-icon layui-icon-vercode"></i></label>
                        <div class="layui-input-block">
                            <div class="layui-row inline-block">
                                <div class="layui-col-xs7">
                                    <input name="verify" type="text" placeholder="验证码" class="layui-input"
                                        autocomplete="off" lay-vertype="tips" lay-verify="required" required="">
                                </div>
                                <div class="layui-col-xs5" style="padding-left: 6px;">
                                    <img id="verify" class="login-captcha" src="{:url('api/checkcode/getVerify')}">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <!-- <a href="javascript:;" class="layui-link">帐号注册</a> -->
                        <!-- <a href="javascript:;" class="layui-link pull-right">忘记密码？</a> -->
                    </div>
                    <div class="layui-form-item">
                        <button lay-filter="login-submit" class="layui-btn layui-btn-fluid" lay-submit>登 录</button>
                    </div>
                </form>
            </div>
        </div>

        <div class="login-footer">
            <p>© 2019 7mae.com 版权所有</p>
            <p>
                <span><a href="https:/www.7mae.com/" target="_blank">技术支持</a></span>
                <span><a href="https:/www.7mae.com/" target="_blank">合作开发</a></span>
            </p>
        </div>
    </div>

    <script type="text/javascript" src="/static/assets/libs/layui/layui.js"></script>
    <script>
        layui.use(['layer', 'form'], function () {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;

            form.on('submit(login-submit)', function (obj) {
                $.ajax({
                    type: "POST",
                    url: "{:url('admin/index/index')}",
                    data: obj.field,
                    dataType: "json",
                    success: function (data) {
                        if (data.code == 0) {
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function () {
                                window.location = "{:url('admin/main/index')}";
                            });
                        } else if (data.code == -1) {
                            layer.msg(data.msg);
                            $("#verify").click();
                        }
                    },
                    error: function (data) {
                        alert("请求失败");
                    }
                });
                return false;
            });
            $("#verify").click(function () {
                var verifyimg = $("#verify").attr("src");
                $("#verify").attr("src", verifyimg.replace(/\?.*$/, '') + '?' + Math.random());
            });
        });
    </script>
</body>

</html>